extends StaticBody2D

@onready var timer: Timer = $Timer
@onready var collision_shape_2d: CollisionShape2D = $CollisionShape2D

var startPos = Vector2(0, -11.5)



func _on_area_2d_body_exited(body: Node2D) -> void:
	if body.name == "Player":
		$Timer.start()



func _on_timer_timeout() -> void:
	var tween = get_tree().create_tween()
	tween.tween_property($Sprite2D, "modulate:a", 0, 0.25)
	$CollisionShape2D.position = Vector2(-1000, -1000)
	$Area2D/CollisionShape2D.position = Vector2(-1000, -1000)
	
func reset():
	var tween = get_tree().create_tween()
	tween.tween_property($Sprite2D, "modulate:a", 1, 0)
	$CollisionShape2D.position = startPos
	$Area2D/CollisionShape2D.position = Vector2(0, -16)
	$Timer.start()
	
func changeColor(r, g, b):
	var tween = get_tree().create_tween()
	
	var color = Color(r, g, b, 1.0)
	
	tween.tween_property($Sprite2D.material, "shader_parameter/color", color, 0.25)
